1. Field of the Invention
The present invention relates to a data receiving apparatus and a data receiving method, and particularly, relates to transmission/reception of a synchronization signal.
2. Description of Related Art
In recent years, needs for a LAN (Local Area Network) mounted on a vehicle increase and a communication protocol optimized for each application is used for LAN mounted on vehicle. LIN (Local Interconnect Network) is a kind of communication protocol for a LAN mounted on vehicle, is a serial communication protocol used in a master/slave configuration, and is used in a simple system mainly having a body system. LIN communication protocol includes Synch Break representing the start of a frame, followed by a field of a synchronization signal called Synch Field. The Synch Field in communication data transmitted from a master side is received on a slave side, and Ident Field and Data Field or other fields flowing subsequent to Synch Filed is received based on a baud rate of Synch Field, as described in Japanese Patent Application Publication (JP-P2004-228945A).
A communication method between a user terminal and a circuit apparatus has been known as a method in which start-stop synchronous serial data is used. In this communication method, specific codes (i.e. 41h and 61h in hexadecimal notation) called an AT commands are initially transmitted. Both of these specific codes use 1 for the least significant bit (LSB), and a space for one bit (i.e. start bit) always appears at the start of communication according to a bit string of LSB first in a serial interface. Time for this space is measured to obtain a communication speed (Japanese Patent Application Publication JP-P2000-209302A).
Japanese Patent Application Publication (JP-P2006-311237A) discloses a technique related to a data receiving apparatus for appropriately detecting Synch Field in the LIN communication protocol. FIG. 1 is a block diagram showing a configuration example of a communication system in this related art, partially showing a binary signal P in the LIN communication protocol. Referring to FIG. 1, the communication system has a slave unit 10 and a master unit 20, which are connected via a bus 30. The master unit 20 transmits the binary signal P on the bus 30. The slave unit 10 receives this binary signal P, and then a predetermined binary signal P is transmitted/received between the slave unit 10 and the master unit 20, as needed.
Referring to a binary signal P in the LIN communication protocol in FIG. 1, Synch Break is a pulse in which a low level of 11 bits or more is continued (between K and L). Synch Field is a synchronization signal of “01010101” (0 and 1 represent a low level and a high level, respectively) from a high level following Synch Break in the low level. Meanwhile, a signal initially received by the slave unit 10 which measures a baud rate based on Synch Field is not limited to Synch Break. It is because the master unit 20 for transmitting the signal is not ensured to operate in synchronization with the slave unit 10 at the time of starting. Accordingly, even if the slave unit 10 focuses attention on a second pulse while acquiring a baud rate by measuring a first pulse width, as described in Japanese Patent Application Publication (JP-P2000-209302A), the second pulse is not ensured to be a start bit of Synch Field. That is, even if a baud rate is acquired from the second pulse to receive subsequent data, data is not appropriately received. Accordingly, Japanese Patent Application Publication (JP-P2006-311237A) proposes the slave unit 10 in which the synchronization signal can be appropriately detected because a frame head is found out by acquiring a ratio of the first pulse width to the second pulse width.
The data receiving apparatus according to Japanese Patent Application Publication (JP-P2006-311237A) will be described. The slave unit 10 includes an edge detecting section 11, a timer 12, a storage section 13, a comparing section 14, a baud rate calculating section 15, a receiving section 16, a transmitting section 17, and a control section 18.
The edge detecting section 11 acquires the binary signal transmitted from the master unit 20 on the bus 30, and detects rising edges of the binary signal P such as L, N and O and falling edges thereof such as K and M. The timer 12 starts at the falling edge and stops at the rising edge. The storage section 13 stores a value of the timer when the timer 12 stops. The comparing section 14 acquires a ratio of a value of the timer 12 to a value stored in the storage section 13 in advance when the timer 12 stops. If the ratio outputted from the comparing section 14 is equal to or more than the predetermined value of, for example, 11, the baud rate calculating section 15 acquires a baud rate of the binary signal P transmitted from the master unit 20 by using an inverse number of a value of the timer 12. It should be noted that a numerical value of 11 is based on the specification of the LIN protocol. The receiving section 16 receives the binary signal P on the bus 30 in accordance with the acquired baud rate. The transmitting section 17 transmits a data signal such as a response to the data signal received by the receiving section 16, onto the bus 30 as needed in accordance with an acquired baud rate. The control section 18 controls the edge detecting section 11, the timer 12, the storage section 13, the receiving section 16 and the transmitting section 17.
An operation of the slave unit 10 to receive the binary signal P will be described. FIG. 2A is a flowchart showing a main process in the slave unit 10 according to the Japanese Patent Application Publication (JP-P2006-311237A). FIG. 2B is a flowchart showing an interrupting process at the falling edge of the binary signal P. FIG. 2C is a flowchart showing the interrupting process at the rising edge of the binary signal P.
A main process shown in FIG. 2A will be first described. The slave unit 10 executes an initializing process to set a variable W100 for storing a pulse width to 0 (step S11), set a variable W200 for storing a pulse width to 0 (step S12), and set a measurement flag M for indicating a state of measuring to 1 so as to represent a measuring state (step S13). Then, an interruption is permitted at the edge of the binary signal P (step S14).
The slave unit 10 waits for completion of the measurement in which the measurement flag M indicates 0 at a step S36 to be described later (step S15). That is, the slave unit 10 checks whether or not the measurement flag M indicates 1, and the step S15 is repeated if the measurement flag M indicates 1. If the measurement flag M does not indicate 1 (i.e. indicates 0), the process flow advances to a step S16 on the assumption that measurement is completed. The slave unit 10 ends a series of processes by prohibiting the interrupting process in the edge detection (step S16).
Next, an interrupting process at a falling edge of the binary signal P will be described with reference to FIG. 2B. The slave unit 10 starts an interrupting process if the edge detecting section 11 detects falling of the binary signal P in a state of permission of the edge interruption. In the falling edge interrupting process, the slave unit 10 executes initialization of the timer 12 (step S21) and start of the timer (step S22). The slave unit 10 returns to the process of the step S15 to determine a state of the measurement flag M in the state of permission of the edge interruption.
Next, an interrupting process at the rising edge of the binary signal P will be described with reference to FIG. 2C. The slave unit 10 starts the interrupting process if the edge detecting section 11 detects the rising edge of the binary signal P in the state of permission of the edge interruption. In the rising edge interrupting process, the slave unit 10 stops the timer 12 (step S31), and sets a value of the timer 12 to the variable W200 (step S32). The slave unit 10 determines whether W100/W200 is equal to or more than 11 (step S33). If W100/W200 is equal to or more than 11, the process flow advances to a step S35 on the assumption that a frame head is detected. In contrast, if W100/W200 is less than 11, the process flow advances to a step S34 on the assumption that a frame head is not detected. It should be noted that, when the process starts by passes through a step S33 initially, the process flow advances to a step S34 because W100 is 0.
The slave unit 10 substitutes the variable W200 for the variable W100 if W100/W200 is less than 11 (step S34). Then, the interrupting process at the rising edge is ended and the process flow returns to the step S15 to wait for subsequent pulse width measurement. If W100/W200 is equal to or more than 11, the slave unit 10 acquires a baud rate by 1/(t×W200) because the variable W200 has a count value of the timer corresponding to one bit width (step S35). Here, t is a resolution of the timer 12. The slave unit 10 sets the measurement flag M to 0 after calculating the baud rate (step S36). Then, the interrupting process at the rising edge is ended and the process flow returns to the step S15.
The slave unit 10 in Japanese Patent Application Publication (JP-P2006-311237A) operates as stated above to obtain a ratio of a first pulse width (i.e. W100) to a second pulse width (i.e. W200). If an acquired ratio is equal to or more than 11, it is determined that the first pulse corresponds to Synch Break and a binary signal following the second pulse corresponds to Synch Field. Then, a baud rate is calculated on the basis of a value of the variable W200 to receive a data field thereafter.
FIG. 3 partially shows a normal binary signal S in the LIN communication protocol. As shown by points A and B in FIG. 3, Synch Break represents a start of a frame in the LIN communication protocol. That is, a time interval between A and B corresponds to a period of time required to transfer a signal in the low level equal to or more than 11 bits. An interval between C and D in a subsequent low level by putting the high level shows a part of Synch Field. Synch Field is modulated for every one bit. That is, the interval between C and D represents a period of time required to transfer one bit. Furthermore, an interval between D and F in the high level and an interval between E and F in the low level show a part of Synch Field similar to that of the interval between C and D, and represent a period of time required to transfer one bit. Synch Field is followed by data in the LIN communication protocol, which is omitted to explain here.
FIG. 4 shows an example in which an abnormal pulse is included in the binary signal S in the LIN communication protocol. Referring to FIG. 4, an interval between a and b shows normal Synch Break in the low level, and an interval between c and d shows an abnormal pulse resulting from external noise or other causes. If the binary signal S shown in FIG. 4 includes the interval between c and d which is an abnormal pulse and a ratio of a pulse width of the interval between a and b relative to a pulse width of the interval between c and d is equal to or more than 11, a technique in Japanese Patent Application Publication (JP-P2006-311237A) may possibly result in erroneously determining that the interval between a and b represents Synch Break and the interval between c and d corresponds to a period of time to transfer one bit in Synch Field. More specifically, Japanese Patent Application Publication (JP-P2006-311237A) can cope with the normal binary signal S as shown in FIG. 3, but it is difficult to sufficiently deal with the binary signal S which includes an abnormal pulse as shown in FIG. 4.